<template>
	<view>
		<uni-section title="用户个人信息" type="line">
			<uni-list>
				<!-- 头像 -->
				<uni-list-item link>
					<template v-slot:header>
						<view class="slot-box">
							<image class="slot-image" :src="user.headImg" mode="widthFix"></image>
						</view>
					</template>
				</uni-list-item>
				
				<!-- 基本信息 -->
				<uni-list-item title="uid" :rightText="user.uid" />
				
				<uni-list-item title="用户权限" :rightText="userType[user.usertype]" />
				
				<uni-list-item title="用户名" :rightText="user.username" />
				<uni-list-item title="真实姓名" :rightText="user.truename" />
				
				<uni-list-item title="性别" :rightText="sexType[user.sex]" />
				
				<uni-list-item title="职称" :rightText="user.rank" />
				
				<uni-list-item title="密码" :rightText="user.password" />
				
				<uni-list-item title="联系方式" :rightText="user.contact" />
			</uni-list>
			
			<!-- 修改信息按钮 -->
			<button class="button" @click="rewrite(user)">修改用户信息</button>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sexType: ['女', '男'],
				userType: ['管理员', '维修人员', '普通用户'],
				user: {
					uid: 10001,  //用户ID
					username: '库克',  //用户名
					sex: 1,  //性别
					rank: '副教授', //职称
					password: '123456789',  //密码
					truename: 'Cook',  //真实姓名
					usertype: 0,  //权限
					contact: '18923042418',  //联系方式
					headImg: "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png"  //头像
				}
			}
		},
		methods: {
			rewrite(user) {
				console.log("跳转到用户信息修改页面")
				uni.navigateTo({
					url:"./rewrite_user?user=" + JSON.stringify(user)
				});
			}
		}
	}
</script>

<style>
	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}
	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 60rpx;
	}
    .slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}
	.button{
		width: 80%;
		margin-top: 30rpx;
		border-radius: 12px;
		border: "#FF0000"
	}
</style>